

// components/card-item/index.ts
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    info: {
      type: Object,
      value: {
        title: "标题",
        description: "描述",
        pic: "https://dss2.bdstatic.com/8_V1bjqh_Q23odCf/pacific/1989763246.jpg?x=0&y=0&h=150&w=242&vh=150.00&vw=242.00&oh=150.00&ow=242.00",
        code: "text",
      }
    },
    width: {
      type: String,
      value: "300rpx"
    },
    height: {
      type: String,
      value: '180rpx'
    },
  },
  observers: {
    height: function (val) {
      let height = parseFloat(val);
      let width = parseFloat(this.properties.width)
      this.setData({
        imgFit: (height / width) > (9 / 16) ? 'contain' : 'fill'
      });
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    imgFit: "fill"
  },
  lifetimes: {
    attached: function () {
      // console.log(this.properties.info.pic);

    }
  },
  /**
   * 组件的方法列表
   */
  methods: {

  }
})
